/**
 * 
 */
package org.wangh.csv.gui;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.wangh.csv.def.Row;

/**
 * @author wang
 *
 */
public class SheetView extends ViewPart {
	
	private CSVSheet csvSheet;
	private Composite parent;

	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public void createPartControl(Composite parent) {
		FillLayout layout = new FillLayout();
		parent.setLayout(layout);
		csvSheet = new CSVSheet(parent, SWT.NONE);
		csvSheet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		this.parent = parent;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
	 */
	@Override
	public void setFocus() {
	}
	
	public void updateView(String viewName, List<Row> rows){
		if(csvSheet == null){
			csvSheet = new CSVSheet(parent, SWT.NONE);
		}
		setPartName(viewName);
		csvSheet.udpate(rows);
	}

}
